﻿using AutoMapper;
using Pay.Core;
using Pay.Data;
using Pay.DTO;
using Pay.IService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pay.Service.AutoMapper {

    public class ProductTokenMakerMapper : IStartupDto {
        private IMapperConfigurationExpression _cfg;
        public ProductTokenMakerMapper(IMapperConfigurationExpression cfg) {
            _cfg = cfg;
        }
        public void Execute() {
            Create();
        }
        protected virtual void Create() {
            _cfg.CreateMap<ProductTokenMaker, product_token_maker_dto>()
                .ForMember(dest => dest.product_id, src => src.MapFrom(c => c.ProductId))
                .ForMember(dest => dest.product_activity_id, src => src.MapFrom(c => c.ProductActivityId))
                .ForMember(dest => dest.first_rate, src => src.MapFrom(c => c.FirstRate))
                .ForMember(dest => dest.second_rate, src => src.MapFrom(c => c.SecondRate))
                 .ForMember(dest => dest.node_mall_rate, src => src.MapFrom(c => c.NodeMallRate))
                 .ForMember(dest => dest.county_agent_rate, src => src.MapFrom(c => c.CountyAgentRate))
                .ForMember(dest => dest.city_agent_rate, src => src.MapFrom(c => c.CityAgentRate))
                .ForMember(dest => dest.cost_price, src => src.MapFrom(c => c.CostPrice))
                .ForMember(dest => dest.distribution_price, src => src.MapFrom(c => c.DistributionPrice))
                .ForMember(dest => dest.product_activity, src => src.MapFrom(c => c.ProductActivity));



            _cfg.CreateMap<product_token_maker_dto, ProductTokenMaker>()
                .ForMember(dest => dest.ProductId, src => src.MapFrom(c => c.product_id))
                .ForMember(dest => dest.ProductActivityId, src => src.MapFrom(c => c.product_activity_id))
                .ForMember(dest => dest.FirstRate, src => src.MapFrom(c => c.first_rate))
                .ForMember(dest => dest.SecondRate, src => src.MapFrom(c => c.second_rate))
                 .ForMember(dest => dest.NodeMallRate, src => src.MapFrom(c => c.node_mall_rate))
                 .ForMember(dest => dest.CountyAgentRate, src => src.MapFrom(c => c.county_agent_rate))
                .ForMember(dest => dest.CityAgentRate, src => src.MapFrom(c => c.city_agent_rate))
                .ForMember(dest => dest.CostPrice, src => src.MapFrom(c => c.cost_price))
                .ForMember(dest => dest.DistributionPrice, src => src.MapFrom(c => c.distribution_price));

            _cfg.CreateMap<ProductTokenMaker, product_token_maker_dto_ex>()
                .ForMember(dest => dest.product_id, src => src.MapFrom(c => c.ProductId))
                .ForMember(dest => dest.product_activity_id, src => src.MapFrom(c => c.ProductActivityId))
                .ForMember(dest => dest.first_rate, src => src.MapFrom(c => c.FirstRate))
                .ForMember(dest => dest.second_rate, src => src.MapFrom(c => c.SecondRate))
                 .ForMember(dest => dest.node_mall_rate, src => src.MapFrom(c => c.NodeMallRate))
                 .ForMember(dest => dest.county_agent_rate, src => src.MapFrom(c => c.CountyAgentRate))
                .ForMember(dest => dest.city_agent_rate, src => src.MapFrom(c => c.CityAgentRate))
                .ForMember(dest => dest.cost_price, src => src.MapFrom(c => c.CostPrice))
                .ForMember(dest => dest.distribution_price, src => src.MapFrom(c => c.DistributionPrice))
                .ForMember(dest => dest.product_activity, src => src.MapFrom(c => c.ProductActivity));


        }
    }
}
